<template>
  <div>
    <div class="page-filter mb10 fl">
      <el-row>
        <el-col :span="24">
          <el-form ref="filter" :model="filter" label-width="0">
            <el-form-item class="mr10 mb5 fl">
              <ProFilter v-model="filter.id" />
            </el-form-item>
            <el-form-item class="mr10 mb5 fl" prop="begin_create_time">
              <el-date-picker
                v-model="filter.begin_create_time"
                placeholder="开始时间"
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                size="small"
                clearable
                style="width: 100%"
              />
            </el-form-item>
            <el-form-item class="mr10 mb5 fl" prop="end_create_time">
              <el-date-picker
                v-model="filter.end_create_time"
                placeholder="结束时间"
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                size="small"
                clearable
                style="width: 100%"
              />
            </el-form-item>
            <el-form-item class="mr10 mb5 fl" style="width: 300px">
              <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
              <el-button type="primary" size="small" @click="getList">查 询</el-button>
              <el-button type="primary" size="small" @click="handleOut">导 出</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="EQ单号" width="190px">
        <template slot-scope="{row}">
          {{ 'EQ'+row.id }}
        </template>
      </el-table-column>
      <el-table-column label="客户名称" width="220px" prop="lc_name" />
      <el-table-column label="项目名称" width="220px" prop="name" />
      <el-table-column label="成本" align="right" width="140px">
        <template slot-scope="{row}">
          {{ app.toFix(row.cost, 2) }}
        </template>
      </el-table-column>
      <el-table-column label="报价金额" align="right" width="140px">
        <template slot-scope="{row}">
          {{ app.toFix(row.quoted_price, 2) }}
        </template>
      </el-table-column>
      <el-table-column label="议价金额" align="right" width="140px">
        <template slot-scope="{row}">
          {{ app.toFix(row.negotiated_price, 2) }}
        </template>
      </el-table-column>
      <el-table-column label="订单金额" align="right" width="140px">
        <template slot-scope="{row}">
          {{ app.toFix(row.trading_price, 2) }}
        </template>
      </el-table-column>
      <el-table-column label="报价人" mwidth="160px" prop="su_quoted_name" />
      <el-table-column label="备注" min-width="260px" prop="bid_remark" />
      <el-table-column label="操作" align="center" width="110px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                @click.native="handleDialog({...row, ...
                {dTitle: '项目投标', dType: 'edit', dField: dField}})"
              >
                投 标
              </el-dropdown-item>
              <el-dropdown-item
                @click.native="files({e_id: row.id, type: '项目投标',
                                      db_type: 'logc_pro_archives'})"
              >
                附 件
              </el-dropdown-item>
              <!-- <el-dropdown-item @click.native="outData(row)">导 出</el-dropdown-item> -->
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Dialog ref="dialog" :get-data="getList" :info="dialog" />
    <Cos ref="cos" :info="dialog" />
  </div>
</template>

<script>
import { pros, outPros } from '@/api/project'
import Dialog from './components/bid-dialog'
import ProFilter from '@/components/ProFilter'
import page from '@/utils/page'

export default {
  name: '',
  components: { ProFilter, Dialog },
  extends: page,
  props: {
    reqList: {
      default: pros,
      type: Function
    }
  },
  data() {
    return {
      parameter: { state: 0 },
      dField: ['id', 'cost', 'quoted_price', 'negotiated_price', 'trading_price', 'su_quoted', 'bid_remark']
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleOut() {
      outPros({
        ...this.filter
      }).then(response => {
        this.out(response)
      }).catch(err => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>
